package com.wx.day07.Cookie;


import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@ResponseBody
@RequestMapping("cookie")
public class CookieController {

    //存一个数据到cookie中
    @GetMapping("save")
    public String save(HttpServletResponse response){
        Cookie cookie = new Cookie("name", "root");
        response.addCookie(cookie);
        return "save";
    }

    @GetMapping("show")
    public String show(@CookieValue(value = "name") String name){
        return name;
    }
}
